package vn.edu.ptithcm.pim.dao;

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import vn.edu.ptithcm.pim.dom.Phase;

public class PhaseDao extends HibernateDaoSupport {
	public void save(Phase phase) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().save(phase);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void saveOrUpdate(Phase phase) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().saveOrUpdate(phase);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void lock(Phase phase) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().lock(phase, LockMode.NONE);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(Phase phase) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().delete(phase);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Phase merge(Phase phase) {
		try {
			return (Phase) getHibernateTemplate().merge(phase);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Phase findById(java.lang.Long id) {
		try {
			return (Phase) getHibernateTemplate().get(Phase.class, id);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	@SuppressWarnings("rawtypes")
	public List findByExample(Phase phase) {
		try {
			return getHibernateTemplate().findByExample("Phase", phase);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	@SuppressWarnings("rawtypes")
	public List getAll() {
		try {
			return getHibernateTemplate().loadAll(Phase.class);
		} catch (RuntimeException re) {
			throw re;
		}
	}
}
